package com.adinnc.vo;

import java.io.Serializable;
import java.util.ArrayList;

import org.jsoup.select.Elements;

import com.adinnc.Util.StringUtils;
import com.adinnc.Util.WordUtils;


//with this annotation we are going to hide compiler warning
 
public class JourneyDetails implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6014219057010249027L;
	public String trainNumber ;
	public String trainName;
	public String trainDate;
	public String from;
	public String to;
	public String reservedUpto;
	public String boardingPoint;
	public String trainClass;
	public ArrayList<PassengerDetails> allPassengers = new ArrayList<PassengerDetails>();
	public String chartStatus;
	
	
	/**
	 * @param links HTML block represents the Journey details & passengers details
	 */
	public JourneyDetails(Elements links) {
		super();
		trainNumber = links.get(0).text();
		trainName = links.get(1).text();
		trainDate = links.get(2).text();
		from = links.get(3).text();
		to = links.get(4).text();
		reservedUpto = links.get(5).text();
		boardingPoint = links.get(6).text();
		trainClass = links.get(7).text();
		for (int i = 8; i < links.size() - 2; i = i + 1) {
			PassengerDetails passengerStatus = new PassengerDetails();
			//if the chart is prepared Coach Position is included so this check
			if(links.get(i).text().contains("Passenger")){
				passengerStatus.sno = links.get(i).text();
				passengerStatus.bookingStatus = links.get(i + 1).text();
				passengerStatus.currentStatus = StringUtils.trimWhitespace(links.get(i + 2).text());
				allPassengers.add(passengerStatus);
			}
		}
		chartStatus = WordUtils.capitalizeFully(links.get(links.size() - 2).text(), null);
	}


	/**
	 * Reset the JourneyDetails Object
	 */
	public void resetJourneyDetails() {
		this.trainNumber = null;
		this.trainName = null;
		this.trainDate = null;
		this.from = null;
		this.to = null;
		this.reservedUpto = null;
		this.boardingPoint = null;
		this.trainClass = null;
		this.allPassengers = new ArrayList<PassengerDetails>(null);
		this.chartStatus = null;
	}
}
